package com.itheima07;

import java.util.Calendar;

/**
 * @author Xiao
 * @date 2021/7/13
 */
public class CalendarDemo02 {
    /**
     * API_Calendar
     */
    public static void main(String[] args) {
        Calendar c = Calendar.getInstance();
        //需求：时间跳到十年后的5天前
        c.add(Calendar.YEAR,10);    //将指定时间量添加或减去给定给指定的日历段
        c.add(Calendar.DAY_OF_YEAR,-5);
        int year = c.get(Calendar.YEAR);
        int month = c.get(Calendar.MONTH) + 1;
        int day = c.get(Calendar.DAY_OF_MONTH);
        System.out.println(year + "年" + month + "月" + day + "日");
        c.set(2018,10,20);  //设置当前年月日
        int year1 = c.get(Calendar.YEAR);
        int month1 = c.get(Calendar.MONTH) + 1;
        int day1 = c.get(Calendar.DAY_OF_MONTH);
        System.out.println(year1 + "年" + month1 + "月" + day1 + "日");
    }
}
